package com.jbm.onehome.iface;

import com.jbm.core.iface.IAcross;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by root on 17-7-5.
 */
@Entity
@Table(name = "callgroup", schema = "", catalog = "")
@org.hibernate.annotations.Entity(dynamicUpdate=true,dynamicInsert=true)
public class CallGroupEntity extends IAcross
{
	public CallGroupEntity()
	{
		super();
	}

	public CallGroupEntity(IAcross ia)
	{
		super(ia);
	}

	public CallGroupEntity(int code, String info)
	{
		super(code,info);
	}

	public CallGroupEntity(String name,String type)
	{
		this();

		this.name = name;
		this.type = type;
	}

	public CallGroupEntity(int cgId,CgUnitEntity cgue)
	{
		this();

		this.cgId = cgId;
		this.unitList = new ArrayList<CgUnitEntity>();
		this.unitList.add(cgue);
	}

	private int cgId;
	private String type;
	private String status;
	private Timestamp createDate;
	private int createId;
	private String name;

	@Id
	@Column(name = "cg_id")
	@GeneratedValue
	public int getCgId()
	{
		return cgId;
	}

	public void setCgId(int cgId)
	{
		this.cgId = cgId;
	}

	@Basic
	@Column(name = "type")
	public String getType()
	{
		return type;
	}

	public void setType(String type)
	{
		this.type = type;
	}

	@Basic
	@Column(name = "status")
	public String getStatus()
	{
		return status;
	}

	public void setStatus(String status)
	{
		this.status = status;
	}

	@Basic
	@Column(name = "create_date")
	public Timestamp getCreateDate()
	{
		return createDate;
	}

	public void setCreateDate(Timestamp createDate)
	{
		this.createDate = createDate;
	}

	@Basic
	@Column(name = "create_id")
	public int getCreateId()
	{
		return createId;
	}

	public void setCreateId(int createId)
	{
		this.createId = createId;
	}

	@Override
	public boolean equals(Object o)
	{
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;

		CallGroupEntity that = (CallGroupEntity) o;

		if (cgId != that.cgId) return false;
		if (createId != that.createId) return false;
		if (type != null ? !type.equals(that.type) : that.type != null) return false;
		if (status != null ? !status.equals(that.status) : that.status != null) return false;

		return true;
	}

	@Override
	public int hashCode()
	{
		int result = cgId;
		result = 31 * result + (type != null ? type.hashCode() : 0);
		result = 31 * result + (status != null ? status.hashCode() : 0);
		result = 31 * result + createId;
		return result;
	}

	@Basic
	@Column(name = "name")
	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	@Transient
	private List<CgUnitEntity> unitList;
	@Transient
	public List<CgUnitEntity> getUnitList()
	{
		return unitList;
	}
	@Transient
	public void setUnitList(List<CgUnitEntity> unitList)
	{
		this.unitList = unitList;
	}

	@Transient
	private ICertAddress[] caddrList;
	@Transient
	public ICertAddress[] getCaddrList()
	{
		return caddrList;
	}
	@Transient
	public void setCaddrList(ICertAddress[] caddrList)
	{
		this.caddrList = caddrList;
	}

	@Transient
	private List<GoodsEntity> goodsList;
	@Transient
	public List<GoodsEntity> getGoodsList()
	{
		return goodsList;
	}
	@Transient
	public void setGoodsList(List<GoodsEntity> goodsList)
	{
		this.goodsList = goodsList;
	}
}
